package org.springside.examples.showcase.wb.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springside.examples.showcase.fulltext.FullTextUtils;
import org.springside.examples.showcase.wb.entity.WbContent;
import org.springside.examples.showcase.wb.service.WbContentManager;

@Controller
@RequestMapping(value = "/wb/search")
public class WbSearchController {
	@Autowired
	private WbContentManager wbContentManager;

	@RequestMapping(value = { "list", "" })
	public String list(HttpServletRequest request, Model model) {
		// List<WbContent> wbContents = wbContentManager.findByMid(3453012225945150l);
		// model.addAttribute("wbContents", wbContents);

		// Page<WbContent> page = new Page<WbContent>();
		// List<WbContent> wbByDate = wbContentManager.getWbByDate(page, "2012-02-03");
		// for (WbContent wbContent : wbByDate) {
		// System.out.println(wbContent.getIr_status_content());
		// }

		String keyword = request.getParameter("keyword");
		if (keyword == null) {
			keyword = "北京";
		}
		List<WbContent> wbList = FullTextUtils.searchDocs(keyword);
		model.addAttribute("wbList", wbList);
		return "wb/wbContentList";
	}
}
